package com.design.proxy.force;

/**
 * @ClassName GamePlayer.java
 * @Description 玩家
 * @author Jon
 * @date 2018年6月14日 上午11:03:32
 */
public class GamePlayer implements IGamePlayer {
	/**
	 * 游戏玩家姓名
	 */
	private String username = "";

	/**
	 * 玩家的代练
	 */
	private IGamePlayer proxy = null;

	public GamePlayer(String username) {
		this.username = username;
	}

	@Override
	public IGamePlayer getProxy() {
		proxy = new GamePlayerProxy(this);
		return proxy;
	}

	@Override
	public void login(String loginName, String password) {
		if (isPeoxy()) {
			System.out.println("登录账号为：" + loginName);
			System.out.println("登录玩家为：" + username);
			System.out.println("登录成功~");
		} else {
			System.out.println("请使用指定代理访问！");
		}
	}

	@Override
	public void killBoss() {
		if (isPeoxy()) {
			System.out.println(username + "击杀BOSS!");
		} else {
			System.out.println("请使用指定代理访问！");
		}
	}

	@Override
	public void upgrade() {
		if (isPeoxy()) {
			System.out.println(username + "升级了!");
		} else {
			System.out.println("请使用指定代理访问！");
		}
	}

	private boolean isPeoxy() {
		if (this.proxy == null) {
			return false;
		} else {
			return true;
		}
	}
}
